﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Identity.Data;
using Microsoft.AspNetCore.Mvc;
using Org.BouncyCastle.Asn1.Ocsp;
using ShortLink.Common.Results;
using SL_Account.Models.Requests;
using SL_Account.Services;

namespace SL_Account.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class UserController : ControllerBase
    {
        private readonly IUserService userService;

        public UserController(IUserService userService)
        {
            this.userService = userService;
        }

        [HttpPost("Register")]
        public Task<JsonData> Register(UserRegisterRequest registerRequest)
        {
            return userService.UserRegister(registerRequest);
        }

        [HttpPost("Login")]
        public Task<JsonData> Login(UserLoginRequest request)
        {
            return userService.Login(request);
        }


        [Authorize]
        [HttpGet("UserDetail")]
        public Task<JsonData> UserDetail() 
        {
            return userService.UserDetail();
        }
     }
}
